/*
 * Condition.cpp
 *
 *  Created on: 15.12.2012
 *      Author: zheka
 */

#include "Condition.hpp"
#include "ScopedLock.hpp"

Condition::Condition() {

	pthread_cond_init(&cond, NULL);
}

Condition::~Condition() {
	pthread_cond_destroy(&cond);
}

void Condition::wait() {
	ScopedLock lock(mutex);
	pthread_cond_wait(&cond, mutex.getMutex());
}

void Condition::notify() {
	ScopedLock lock(mutex);
	pthread_cond_signal(&cond);
}
